An encoder encodes an input image into an output image to compress the input image having a large data volume into the output image having a small data volume. The encoder generates a prediction image on the basis of the input image and a reference image and further generates a differential image on the basis of the input image and the prediction image. The encoder can improve the compression coding efficiency by encoding the differential image without encoding the input image.
An encoder disclosed in Patent Document 1 calculates a prediction error of each image on the basis of an input image and a prediction image in order to evaluate the quality of each image. Herein, the prediction error refers to a sum of absolute differences (SAD) obtained by adding up differential absolute values of corresponding pixel values of the input image and the prediction image with respect to all the corresponding pixels. Alternatively, the prediction error refers to a sum of square differences (SSD) obtained by adding up differential square values of corresponding pixel values of the input image and the prediction image with respect to all the corresponding pixels.
When the encoder determines that the prediction error of an image to be currently encoded sharply increases, the encoder estimates that the quality of the image to be currently encoded is sharply degraded. Then, for an image to be encoded next, the encoder allocates the target amount of codes larger than that of the image to be currently encoded. Thus, the encoder can improve the quality of the image to be encoded next as compared with the quality of the image to be currently encoded. Further, the encoder can avoid an overflow of an output image buffer.    [Patent Document 1] Japanese Patent Application Laid Open Gazette No. 2002-125235
The encoder disclosed in Patent Document 1 can improve the quality of the image to be encoded next even if the quality of the image to be currently encoded is degraded. When the qualities of images in a whole stream are not uniform, however, since an image of high quality and an image of low quality alternately appear, there occurs flicker and the image quality is thereby subjectively degraded. In a whole stream having a little motion, particularly, the subjective degradation of image quality is remarkable.